# -*- coding=utf-8 -*-
# @time:2021/8/4
# @phone:15874198829
# @author:码尚教育_星瑶
import time

from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# 设置操控终端的配置参数
desired_caps={
    "automationName":"UiAutomator2", #默认框架
    "platformName":"Android", #指定操作系统
"platformVersion":"5.1.1",#指定系统版本
    "deviceName":"127.0.0.1:62001",#指定设备名称
    "appPackage":"com.tencent.mobileqq",#被操作的应用程序包名
    "appActivity":"com.tencent.mobileqq.activity.LoginActivity" , #启动页面
    "noReset":"True"   #  为true 不重置  为false 重置
}
# 发送指令给appium server
driver=webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps)
# 定位登录
el_login=driver.find_element(MobileBy.ID,"com.tencent.mobileqq:id/btn_login")
el_login.click()
# 等待  三大等待 =web自动测试三大等待  显示等待  content-desc/description属性值:请输入QQ号码或手机或邮箱
loc=(MobileBy.ACCESSIBILITY_ID,"请输入QQ号码或手机或邮箱")
WebDriverWait(driver,20).until(EC.visibility_of_element_located(loc))

# 定位方式三：基于content-desc/description属性定位：MobileBy.ACCESSIBILITY_ID
el6=driver.find_element(*loc)
el7=driver.find_element_by_accessibility_id(loc[1])
el6.send_keys("2155896749")
time.sleep(2)
